package com.example.g32.park

import android.graphics.Color
import androidx.databinding.DataBindingUtil
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.base.entity.ParkEntityItem
import com.example.g32.R
import com.example.g32.databinding.ItemParkBinding

class ParkAdapter2:BaseQuickAdapter<ParkEntityItem, BaseViewHolder>(R.layout.item_park) {
    override fun onItemViewHolderCreated(viewHolder: BaseViewHolder, viewType: Int) {
        super.onItemViewHolderCreated(viewHolder, viewType)
        DataBindingUtil.bind<ItemParkBinding>(viewHolder.itemView)
    }
    override fun convert(helper: BaseViewHolder, item: ParkEntityItem) {
        val binding = DataBindingUtil.getBinding<ItemParkBinding>(helper.itemView)
        binding?.bean=item
        binding!!.parkStatus.apply {
            when(item.spaceStatus){
                "空闲"->{
                    setTextColor(context.getColor(R.color.green))
                    setBackgroundResource(R.drawable.shape_status)
                }
                "已占用"->{
                    setTextColor(Color.BLUE)
                    setBackgroundResource(R.drawable.shape_zhanyong)
                }
                else->{
                    setTextColor(context.getColor(R.color.orange))
                    setBackgroundResource(R.drawable.shape_weihu)
                }
            }
        }
    }
}